<template>
  <div>
    <div
      class="wrapper-container"
      style="display: flex; flex-direction: column; width: 100%; margin: 0 50px"
    >
      <div class="search-container">
        <div class="search-container-left">
          <div
            class="search-container-item"
            v-for="(select, index) in selectList"
            :key="index"
          >
            <div v-if="select.type === 'select'" class="box">
              <span v-show="select.name">{{ select.name }}</span>

              <el-select
                v-model="select.val"
                style="width: 120px"
                size="mini"
                placeholder="请选择"
              >
                <el-option
                  v-for="item in select.valList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </div>
            <div class="box" v-if="select.type === 'data'">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-date-picker
                v-model="select.val"
                type="date"
                placeholder="选择日期"
                prefix-icon="aaa"
              >
              </el-date-picker>
            </div>
            <div v-if="select.type === 'MultiSelect'" class="box"></div>
            <div v-if="select.type === 'btn'" class="box">
              <span class="demonstration" v-show="select.name">{{
                select.name
              }}</span>
              <el-input
                v-model="select.val"
                placeholder="请输入内容"
              ></el-input>
            </div>
          </div>
          <div class="search-button" style="margin-left: 20px">
            <img src="../../../../assets/assessment/icon-search.png" alt="" />
            <span>查询</span>
          </div>
        </div>
      </div>
    </div>
    <div
      class="export-top"
      style="float: right; margin-top: -40px; margin-right: 20px"
    >
      <img src="../../../../assets/assessment/icon-export.png" alt="" />
      <download-excel
        class="export-btn"
        :data="tableData"
        :fields="jsonFields"
        type="xls"
        name="时间段课表.xls"
        style="color: #f3b815"
      >
        &ensp;导出Excel
      </download-excel>
    </div>

    <div class="body-manual-container">
      <div>
        <ul>
          <li>
            <span><div>节次</div></span>
            <span><div>星期一</div></span>
            <span><div>星期二</div></span>
            <span><div>星期三</div></span>
            <span><div>星期四</div></span>
            <span><div>星期五</div></span>
            <span><div>星期六</div></span>
            <span><div>星期日</div></span>
          </li>
          <li v-for="(item, key) in tableList" :key="key">
            <span>
              <div>
                <div>{{ key }}</div>
              </div>
            </span>
            <span
              ><div>
                <div v-if="item['星期一'] != {}">
                  <span v-for="da in item['星期一']"
                    >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                      da["courseweeks"]
                    }}</span
                  >
                </div>
                <br style="clear: both" /></div
            ></span>
            <span>
              <div v-if="item['星期一'] != {}">
                <span v-for="da in item['星期二']"
                  >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                    da["courseweeks"]
                  }}</span
                >
              </div>
            </span>
            <span>
              <div v-if="item['星期一'] != {}">
                <span v-for="da in item['星期三']"
                  >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                    da["courseweeks"]
                  }}</span
                >
              </div>
            </span>
            <span>
              <div v-if="item['星期一'] != {}">
                <span v-for="da in item['星期四']"
                  >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                    da["courseweeks"]
                  }}</span
                >
              </div>
            </span>
            <span>
              <div v-if="item['星期一'] != {}">
                <span v-for="da in item['星期五']"
                  >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                    da["courseweeks"]
                  }}</span
                >
              </div>
            </span>
            <span>
              <div v-if="item['星期一'] != {}">
                <span v-for="da in item['星期六']"
                  >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                    da["courseweeks"]
                  }}</span
                >
              </div>
            </span>
            <span>
              <div v-if="item['星期一'] != {}">
                <span v-for="da in item['星期日']"
                  >{{ da["coursename"] }},{{ da["courseplace"] }},{{
                    da["courseweeks"]
                  }}</span
                >
              </div>
            </span>
          </li>
          <li>
            <span><div>备注</div></span>
            <span><div style="width: 1525px"></div></span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
import tablelist from "@/views/comonents/tablelist";
import ButtonItem from "@/components/ButtonItem.vue";
import SelectItem from "@/components/SelectItem.vue";
import { queryProfessionalTimeTable } from "@/api/trainingManagement/place.js";
export default {
  components: {
    tablelist,
    ButtonItem,
    SelectItem,
  },
  data() {
    return {
      tableList: {}, //
      selectList: [
        {
          type: "select",
          name: "课表类型:",
          val: "专业班次课表",
          valList: [
            {
              value: "专业班次课表",
              label: "专业班次课表",
            },
            {
              value: "场地课表",
              label: "场地课表",
            },
          ],
        },
      ],
      newTableList: [], //导出数据
    };
  },
  created() {},
  mounted() {
    this.queryProfessionalTimeTable();
  },
  methods: {
    async queryProfessionalTimeTable() {
      var name = this.selectList[0].val; //教员姓名
      var data = {
        map: {
          "7-8": {},
          "1-2": {
            星期三: [
              {
                coursename: "1",
                courseplace: "场地2",
                courseweeks: "5",
              },
            ],
            星期一: [
              {
                coursename: "1",
                courseplace: "场地3",
                courseweeks: "3,4,10,11",
              },
            ],
          },
          "3-4": {
            星期三: [
              {
                coursename: "1",
                courseplace: "场地2",
                courseweeks: "5",
              },
            ],
          },
          "5-6": {
            星期五: [
              {
                coursename: "1",
                courseplace: "场地3",
                courseweeks: "7",
              },
            ],
          },
        },
      };
      this.tableList = data.map;
      this.newTableList = [];
      for (const key in data.map) {
        var one = "";
        if (
          data.map[key]["星期一"] != undefined &&
          data.map[key]["星期一"] != null
        ) {
          one =
            data.map[key]["星期一"][0].coursename +
            "," +
            data.map[key]["星期一"][0].courseplace +
            "," +
            data.map[key]["星期一"][0].courseweeks;
        }

        var two = "";
        if (
          data.map[key]["星期二"] != undefined &&
          data.map[key]["星期二"] != null
        ) {
          two =
            data.map[key]["星期二"][0].coursename +
            "," +
            data.map[key]["星期二"][0].courseplace +
            "," +
            data.map[key]["星期二"][0].courseweeks;
        }

        var three = "";
        if (
          data.map[key]["星期三"] != undefined &&
          data.map[key]["星期三"] != null
        ) {
          one =
            data.map[key]["星期三"][0].coursename +
            "," +
            data.map[key]["星期三"][0].courseplace +
            "," +
            data.map[key]["星期三"][0].courseweeks;
        }

        var four = "";
        if (
          data.map[key]["星期四"] != undefined &&
          data.map[key]["星期四"] != null
        ) {
          one =
            data.map[key]["星期四"][0].coursename +
            "," +
            data.map[key]["星期四"][0].courseplace +
            "," +
            data.map[key]["星期四"][0].courseweeks;
        }

        var five = "";
        if (
          data.map[key]["星期五"] != undefined &&
          data.map[key]["星期五"] != null
        ) {
          one =
            data.map[key]["星期五"][0].coursename +
            "," +
            data.map[key]["星期五"][0].courseplace +
            "," +
            data.map[key]["星期五"][0].courseweeks;
        }

        var six = "";
        if (
          data.map[key]["星期六"] != undefined &&
          data.map[key]["星期六"] != null
        ) {
          one =
            data.map[key]["星期六"][0].coursename +
            "," +
            data.map[key]["星期六"][0].courseplace +
            "," +
            data.map[key]["星期六"][0].courseweeks;
        }

        var seven = "";
        if (
          data.map[key]["星期日"] != undefined &&
          data.map[key]["星期日"] != null
        ) {
          one =
            data.map[key]["星期日"][0].coursename +
            "," +
            data.map[key]["星期日"][0].courseplace +
            "," +
            data.map[key]["星期日"][0].courseweeks;
        }
        var par = {
          jc: key, //节次
          星期一: one,
          星期二: two,
          星期三: three,
          星期四: four,
          星期五: five,
          星期六: six,
          星期日: seven,
        };
        this.newTableList.push(par);
      }
      console.log(this.newTableList, "111111111111");
      console.log(this.tableList, "tableList ==== ");
      // const res = await queryProfessionalTimeTable(name);
      // if (res.data.code == 200) {
      //   console.log(res.data, "res ====")
      //   // this.tableData = res.data.data;
      // }
    },
  },
  computed: {}, //计算属性
};
</script>
<style lang="less" scoped>
@import "../../../../styles/text.less";
.pagination-block {
  margin-top: 20px;
  display: flex;
  flex-direction: row;
  justify-content: center;
}
</style>
<style lang="less" scoped>
@import "../../../../styles/supervision.less";

.wrapper-container {
  width: 1711px;
  margin: 0 auto;
}

/deep/ .table-container {
  .el-table td,
  .el-table th.is-leaf,
  .el-table--border,
  .el-table--group {
    border-color: #c7d7eb;
  }

  .el-table__header tr,
  .el-table__header th {
    padding: 0;
    height: 76px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  .el-table__body tr,
  .el-table__body td {
    padding: 0;
    height: 86px;
  }

  .wrapper-button {
    display: flex;
    flex-direction: column;
    align-items: center;

    > div {
      margin-bottom: 8px;
    }
  }
  .table-data {
    width: 100%;
    border: 0.8px solid #004ca7;
    /*border-radius: 9px;*/
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #004ca7;
  }
}

.wrapper-container .search-container .search-container-left {
  width: 100%;
  flex-wrap: wrap;
  .search-container-item {
    width: 12%;
    margin-right: 0px;
    .box {
      > span {
        text-align: left;
      }
      display: flex;
      justify-content: space-evenly;
      margin-bottom: 20px;
      align-items: center;
    }
  }
}

/deep/.el-date-editor.el-input {
  width: 110px;
}
/deep/ .el-input--medium {
  width: 110px;
  .el-input__inner {
    height: 28px;
    width: 110px;
    padding: 0px 18px;
  }
}
/deep/ .el-table thead {
  color: #004ca7 !important;
}

.btn {
  margin-top: 271px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 271px;
  .submit {
    width: 84px;
    height: 27px;
    line-height: 8px;
  }
}
.bottom-block {
  // display: flex;
  flex-direction: row;
  justify-content: space-between !important;
  .export-button {
    width: 127px;
    height: 27px;
    background: #fff6ef;
    border: 1px solid #f3b815;
    border-radius: 4px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    > img {
      width: 17px;
      height: 17px;
    }
    > span {
      margin-left: 12px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #f3b815;
    }
  }
  .text {
    font-size: 14px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    line-height: 39px;
    color: #004ca7;
  }
}

.search-button {
  width: 77px;
  height: 28px;
  line-height: 28px;
  background: #f1f8fe;
  border: 1px solid #51aef6;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  > span {
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: 400;
    color: #51aef6;
  }
  > img {
    width: 20px;
    height: 20px;
    margin-right: 4px;
  }
}

.body-manual-container {
  > div:nth-child(1) {
    width: calc(100% - 20px);
    // height: 785px;
    border: 1px solid rgba(0, 76, 167, 0.8);
    border-radius: 6px;
    margin: 30px auto 0;
    ul {
      list-style: none;
      li:nth-child(n) {
        border-bottom: 1px solid rgba(0, 76, 167, 0.4);
        height: auto;
        > span {
          box-sizing: border-box;
          display: inline-block;
          font-size: 14px;
          color: rgba(0, 76, 167, 1);
          border-right: 1px solid rgba(0, 76, 167, 0.4);
          height: 60px;
          vertical-align: middle;
          &:nth-child(n) {
            width: 12.5%;
            height: 100px;
          }
          &:last-child {
            border-right: none;
          }
          &.active {
            font-size: 16px;
            color: rgba(0, 76, 167, 1);
            font-weight: bold;
            background: rgba(77, 129, 192, 0.1);
            text-align: center;
            padding-left: 0;
          }
          > span {
            color: rgba(255, 56, 25, 1);
          }
          > div {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
          }
        }
      }
      li:nth-child(1) {
        > span {
          &:nth-child(n) {
            width: 12.5%;
            height: 60px;
            font-weight: bold;
          }
          > div {
            width: 100%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 16px;
          }
        }
      }
    }
  }
}

.export-right {
  display: flex;
  align-items: center;
  justify-content: end;
  margin-right: 70px;
  margin-top: -50px;
}

.assessment-container {
  width: calc(100% - 20px);
  .table-container {
    width: 100%;
  }
}

.export-top {
  cursor: pointer;
  width: 127px;
  height: 27px;
  background: #fff6ef;
  border: 1px solid #f3b815;
  border-radius: 4px;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  flex-direction: row;
  -webkit-box-align: center;
  align-items: center;
  -webkit-box-pack: center;
  justify-content: center;
  > img {
    width: 17px;
    height: 17px;
  }
}
</style>
